package com.test.netty.nettyhb;

public class ProtobufUtils {

    public static CProtocol.Message createMessage(CProtocol.Heartbeat heartbeat) {
        CProtocol.Message.Builder builder = CProtocol.Message.newBuilder();
        builder.setType(CProtocol.EnumDataType.HEARTBEAT);
        builder.setHeartbeat(heartbeat);
        return builder.build();
    }

    public static CProtocol.Message createMessage(CProtocol.Request req) {
        CProtocol.Message.Builder builder = CProtocol.Message.newBuilder();
        builder.setType(CProtocol.EnumDataType.REQUEST);
        builder.setRequest(req);
        return builder.build();
    }

    public static CProtocol.Message createMessage(CProtocol.Response resp) {
        CProtocol.Message.Builder builder = CProtocol.Message.newBuilder();
        builder.setType(CProtocol.EnumDataType.RESPONSE);
        builder.setResponse(resp);
        return builder.build();
    }
}
